#ifndef _SSD1306_H
#define _SSD1306_H
#include "system_cw32l010.h"
#include "cw32l010_gpio.h"
#include "cw32l010_spi.h"
#include "cw32l010_sysctrl.h"

typedef struct 
{
    uint8_t bright_levl; //背光
}oled_info_t;


// sck pa05
#define SPI_SCK_GPIO_CLK SYSCTRL_AHB_PERIPH_GPIOA
#define SPI_SCK_GPIO_PORT CW_GPIOA
#define SPI_SCK_GPIO_PIN GPIO_PIN_5
#define SPI_SCK_AF() PA05_AFx_SPI1SCK()
// mosi pa06
#define SPI_MOSI_GPIO_CLK SYSCTRL_AHB_PERIPH_GPIOA
#define SPI_MOSI_GPIO_PORT CW_GPIOA
#define SPI_MOSI_GPIO_PIN GPIO_PIN_6
#define SPI_MOSI_AF() PA06_AFx_SPI1MOSI()
// spi_cs
#define SPI_CS_GPIO_CLK SYSCTRL_AHB_PERIPH_GPIOB
#define SPI_CS_GPIO_PORT CW_GPIOA
#define SPI_CS_GPIO_PIN GPIO_PIN_2
#define SPI_CS_AF() PA02_AFx_SPI1NCS()

// CS LOW or HIGH
#define SPI_CS_LOW() PA02_SETLOW()
#define SPI_CS_HIGH() PA02_SETHIGH()

#define DC_WRITE_CMD() PA04_SETLOW()
#define DC_WRITE_DATA() PA04_SETHIGH()

void OLED_GPIO_INTI(void);
void OLED_SPI_INIT(void);
void OLED_Inti(void);
void OLED_Clear(void);
void OLED_ClearArea(uint8_t x_start, uint8_t y_start, uint8_t x_end, uint8_t y_end);
void OLED_Refresh_GRAM(void);
void OLED_Show_String(uint8_t x, uint8_t y, const uint8_t *p, uint8_t size, uint8_t mode);
void OLED_DEMO(void);
void OLED_CTRL_BL(uint8_t mode);
void OLED_FM(void);
void OLED_TIME(void);

#endif // !_SSD1306_H